﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using HNCDataSetTableAdapters;

public partial class UserControl_content_contact : System.Web.UI.UserControl
{
    InfoTableAdapter info = new InfoTableAdapter();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ltrMap.Text = loadMap();
        }
    }

    public string loadMap()
    {
        string tem = "";
        DataTable dt = info.GetInfoByID(1);
        lblTitle.Text = FuntionHNC.GetLanguage(dt.Rows[0]["Title"].ToString(), dt.Rows[0]["Title_en"].ToString());
        lblAddress.Text = FuntionHNC.GetLanguage(dt.Rows[0]["Address"].ToString(), dt.Rows[0]["Address_en"].ToString());
        lblPhone.Text = dt.Rows[0]["Phone"].ToString();
        lblFax.Text = dt.Rows[0]["Fax"].ToString();
        lblEmail.Text = dt.Rows[0]["Email"].ToString();
        string GoogleMap = dt.Rows[0]["GoogleMap1"].ToString();
        tem += "<iframe width=\"580\" height=\"580\" frameborder=\"0\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" src=\"";
        tem += GoogleMap;
        tem += "\"></iframe><br /><small><a href=\"";
        tem += GoogleMap;
        tem += "\" style=\"color: #0000FF; text-align: left\">Xem Bản đồ cỡ lớn hơn</a></small>";
        return tem;
    }

    protected void btnSend_Click(object sender, EventArgs e)
    {
        try
        {
            DataTable dt = info.GetInfoByID(1);
            string mailto = dt.Rows[0]["Email"].ToString();

            string temp = @"<table align='center' cellpadding='0' cellspacing='0'  style='color: #666666; font-size: small; font-family: Arial, Helvetica, sans-serif;' width='720'>    

            <tr>
                <td align='left' colspan='2' height='50' class='auto-style5'>
                    Thông tin liên hệ</td>
            </tr>
            <tr>
                <td align='left' 
                    style='border-bottom: 1px dashed #CCCCCC; text-align: right; border-left-color: #CCCCCC; border-right-color: #CCCCCC; border-top-color: #CCCCCC; padding-right: 10px;' 
                    width='150'>
                    Họ và tên</td>
                <td align='left' 
                    style='border-color: #CCCCCC; padding: 3px; border-bottom-style: dashed; border-bottom-width: 1px; text-align: left;' class='auto-style3'>
                    " + txtName.Text + @"</td>
            </tr>

            <tr>
                <td align='left' 
                    style='border-bottom: 1px dashed #CCCCCC; text-align: right; border-left-color: #CCCCCC; border-right-color: #CCCCCC; border-top-color: #CCCCCC; padding-right: 10px;' 
                    width='150'>
                    E-mail</td>
                <td align='left'
                    style='border-color: #CCCCCC; padding: 3px; border-bottom-style: dashed; border-bottom-width: 1px; text-align: left;' class='auto-style3'>
                    " + txtEmail.Text + @"</td>
            </tr>

            <tr>
                <td align='left' 
                    style='border-bottom: 1px dashed #CCCCCC; text-align: right; border-left-color: #CCCCCC; border-right-color: #CCCCCC; border-top-color: #CCCCCC; padding-right: 10px;' 
                    width='150'>
                    Nội Dung Liên Hệ</td>
                <td align='left' 
                    style='border-color: #CCCCCC; padding: 3px; border-bottom-style: dashed; border-bottom-width: 1px; text-align: left;'>
                    " + txtContent.Text + @"</td>
            </tr>
            </table>";

            FuntionHNC.sendmail(txtEmail.Text, mailto, txtEmail.Text, "Liên hệ từ website", temp);

            txtName.Text = "";
            txtEmail.Text = "";
            txtContent.Text = "";

            lblMsg.Text = FuntionHNC.GetLanguage("Đã gởi thông tin liên hệ.<br/> Chúng tôi sẽ liên hệ đến bạn trong thời gian sớm nhất.", "Sent contact information. <br/> We will contact to you as soon as possible.");

        }
        catch (Exception)
        {
            return;
        }

    }

}
